﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using FogOutlook.Plugins.Classes;

namespace FogOutlook {
	public partial class LoginForm : Form {
		public LoginForm() {
			InitializeComponent();
			System.Drawing.Bitmap bmp = Properties.Resources.FogOutlook;
			this.Icon = System.Drawing.Icon.FromHandle(bmp.GetHicon());
			foreach(KeyValuePair<string, BugTrackerBase> bt in PluginLoader.Plugins) {
				int pos = btType.Items.Add(bt.Value);
			}
			if(btType.Items.Count > 0)
				//btType..SelectedItem = 0;
				btType.SelectedIndex = 0;
		}

		private void loginBtn_Click(object sender, EventArgs e) {
			if(btURL.Text.Length == 0) {
				MessageBox.Show("Please enter a URL to connect to.");
				btURL.Focus();
				return;
			}
			if(username.Text.Length == 0) {
				MessageBox.Show("Please enter a username.");
				username.Focus();
				return;
			}
			if(password.Text.Length == 0) {
				MessageBox.Show("Please enter a password");
				password.Focus();
				return;
			}
			Properties.Settings.Default.bttype = btType.Text; // Why doesn't it save with the data binding?
		}
	}
}
